#include<iostream>
using namespace std;
class Solution {
public:
	string countAndSay(int n)
	{
		string s1 = "1";
		string s2;
		for (int i = 0; i < n-1; i++)
		{
			for (int j = 0; j < s1.size(); j++)
			{
				int count = 1;
				while (j < s1.size() && s1[j] == s1[j + 1])
				{
					count++;
					j++;
				}
				s2 += count + '0';
				s2 += s1[j];
			}
			s1 = s2;
			s2.clear();
		}
		return s1;
	}
};
int main()
{
   Solution s;
  cout<< s.countAndSay(4);
}
